import {createSlice,PayloadAction} from "@reduxjs/toolkit";

//定义动画状态的接口
interface AnimationState{
    activeAnimationIndex:number;
}
//初始状态
const initialState:AnimationState={
    activeAnimationIndex:0
};
//创建动画slice
const animationSlice=createSlice({
    name:'animation',
    initialState,
    reducers:{
        //切换动画的action
        switchAnimation:(state,action:PayloadAction<number>)=>{
            state.activeAnimationIndex=action.payload
        }
    }
});
//导出action和reducer
export const {switchAnimation}=animationSlice.actions;
export default animationSlice.reducer;